package com.sgb.jicai.viewmodel;

import androidx.lifecycle.ViewModel;

import com.sgb.jicai.base.JiCaiBaseApi;
import com.sgb.jicai.view.activity.FactoryCentralizedActivity;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.util.PickSelectEntity;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import java.util.List;

public class FactoryCentralizedModel extends ViewModel {

    public void groupBuyClassList(FactoryCentralizedActivity activity) {
        DialogHelper.showProgressDialog(activity, null, "加载中...", 0, true, null).setCanceledOnTouchOutside(false);
       JiCaiBaseApi.getApi().groupBuyClassList().enqueue(new ICallBack<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<PickSelectEntity>> data) {
                if (data == null || data.getState() == null) {
                    activity.showEmpty();
                    return;
                }
                if (data.getState().equals(JiCaiBaseApi.RESPONSE_OK)) {
                    activity.updateViews(data.getData());
                } else {
                    activity.showEmpty();
                }
            }
        });
    }
}
